var mongoose = require('mongoose')
var Schema = mongoose.Schema

mongoose.connect('mongodb://localhost/User', { useNewUrlParser: true, useUnifiedTopology: true })
mongoose.set('useFindAndModify', false)

var userSchema = new Schema({
    email: {
        type: String,
        required: true
    },
    username: {
        type: String,
        required: true
    },
    Avatar: {
        type:String,
        default: 'http://47.98.244.44:3000/public/img/defaultAvatar.png'
    },
    password: {
        type: String,
        required: true
    },
    create_time: {
        type: Date,
        default: Date.now()
    },
    role: {
        type: String,
        default: '普通用户'
    },
    user_state: {
        type: Boolean,
        default: true
    },
    levels: {
        type: Number,
        default: 1
    },
    userDescription: {
        type: String,
        default: '普通人'
    },
    introduce: {
        type: String,
        default: '暂无个人介绍'
    },
    collections: [String]
})

module.exports = mongoose.model('User', userSchema)